﻿<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:s="clr-namespace:WPFDemo.Presentation.Controls.Spinner"
    >
    <Style TargetType="{x:Type s:ButtonSpinner}">
        <Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.WindowBrushKey}}" />
        <Setter Property="BorderBrush" Value="{DynamicResource {x:Static SystemColors.ControlDarkBrushKey}}" />
        <Setter Property="BorderThickness" Value="1pt" />
        <Setter Property="Focusable" Value="False" />
        <Setter Property="Padding" Value="2pt" />
        <Setter Property="HorizontalContentAlignment" Value="Stretch" />
        <Setter Property="VerticalContentAlignment" Value="Center" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type s:ButtonSpinner}">
                    <Grid SnapsToDevicePixels="True"                          
                          >
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*" />
                            <ColumnDefinition Width="Auto" />
                        </Grid.ColumnDefinitions>
                        <Border x:Name="PART_Border" 
                                Background="{TemplateBinding Background}" 
                                BorderBrush="{TemplateBinding BorderBrush}"
                                BorderThickness="{TemplateBinding BorderThickness}"
                                Grid.ColumnSpan="2"
                                />
                        <ContentPresenter x:Name="PART_ContentPresenter" 
                                          Grid.Column="0"
                                          Focusable="False"
                                          Margin="{TemplateBinding Padding}"
                                          HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                          VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                          SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"                                          
                                          />
                        <Grid Grid.Column="1"
                              Width="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}"
                              >
                            <Grid.RowDefinitions>
                                <RowDefinition Height="*" />
                                <RowDefinition Height="*" />
                            </Grid.RowDefinitions>
                            <RepeatButton x:Name="PART_UpButton" 
                                          Grid.Row="0" 
                                          HorizontalContentAlignment="Center" VerticalContentAlignment="Center"
                                          Margin="0"
                                          Padding="-1"
                                          Focusable="False"
                                          IsTabStop="False"
                                          FontFamily="Webdings"
                                          FontSize="6pt"
                                          Content="5"
                                          />
                            <RepeatButton x:Name="PART_DownButton" 
                                          Grid.Row="1"
                                          HorizontalContentAlignment="Center" VerticalContentAlignment="Center"
                                          Margin="0"
                                          Padding="-1"
                                          Focusable="False"
                                          IsTabStop="False"
                                          FontFamily="Webdings"
                                          FontSize="6pt"
                                          Content="6"
                                          />
                        </Grid>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.ControlLightBrushKey}}" />
                        </Trigger>
                        <Trigger SourceName="PART_UpButton" Property="IsEnabled" Value="False">
                            <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}" />
                        </Trigger>
                        <Trigger SourceName="PART_DownButton" Property="IsEnabled" Value="False">
                            <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>

